package com.sy.controller.inventory;

import com.sy.bean.inventory.InventoryCont;
import com.sy.bean.inventory.InventoryContQuery;
import com.sy.common.bean.PageBean;
import com.sy.common.bean.ResultBean;
import com.sy.common.controller.BaseController;
import com.sy.common.utils.BeanOfMap;
import com.sy.service.inventory.InventoryContService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "库存盘点列表")
@RequestMapping("/api/InventoryCont")
public class InventoryContController extends BaseController {

    @Autowired
    InventoryContService inventoryContService;

    @PostMapping("/query")
    @ApiOperation(value = "查询库存盘点列表")
    public ResultBean query(@RequestBody InventoryContQuery query) {
        PageBean pageBean = inventoryContService.query(BeanOfMap.bom(query));
        return success("查询成功", pageBean);
    }

    @GetMapping("/queryDetail")
    @ApiOperation(value = "查询库存盘点明细")
    public ResultBean queryDetail(int id) {
        return success("查询成功", inventoryContService.queryDetail(id));
    }

    @PostMapping("/insert")
    @ApiOperation(value = "添加库存盘点")
    public ResultBean insert(@RequestBody InventoryCont inventoryCont) {
        int rs = inventoryContService.insert(inventoryCont);
        return rs > 0 ? success("添加成功") : fail("添加失败");
    }

    @GetMapping("/delete")
    @ApiOperation(value = "删除库存盘点")
    public ResultBean update(int id) {
        int rs = inventoryContService.delete(id);
        return rs > 0 ? success("删除成功") : fail("删除失败");
    }

}
